package com.dc.seckill.redis;

/**
 * @模块 redis缓存模块
 * @作者 djs
 * @时间 2018/3/13 22:12
 * @版本 V1.0
 * @描述 缓存key基础类
 */
public abstract class BasePrefix implements KeyPrefix {

    private int expireSecond;    //缓存有效时间，0表示永久

    private String prefix;    //缓存key名称

    public BasePrefix(String prefix){
        this.expireSecond = 0;
        this.prefix = prefix;
    }

    public BasePrefix(int expireSecond,String prefix){
        this.expireSecond = expireSecond;
        this.prefix = prefix;
    }

    @Override
    public int expireSeconds() {
        return expireSecond;
    }

    @Override
    public String getPrefix() {
        String clazz = getClass().getSimpleName();
        return clazz + ":" +prefix;
    }

}
